package com.sz.szaiagent.agent;

import com.sz.szaiagent.agent.BaseAgent;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public abstract class ReActAgent extends BaseAgent {
    /**
     * 处理当前状态并且决定下一步
     */
    public abstract boolean think();
    /**
     * 执行决定的行动
     */
    public abstract String act();
    /**
     * 执行单步：思考与行动
     */
    @Override
    public String step() {
        try{
            boolean shouldAct = think();
            if(!shouldAct)
            {
                return "思考完成--无需行动";
            }
            return act();
        }catch (Exception e){
            e.printStackTrace();
            return "步骤执行失败："+e.getMessage();
        }
    }
}
